'use strict'

// 查找
function getList(keyword){
    return new Promise((resolve,reject)=>{
        $.get(`${baseUrl}/students?keyword=${keyword}`,res=>{
            resolve(res.data)
        })          
    })
}

// 删除
function delStudent(id){
    return new Promise((resolve,reject)=>{
        $.ajax({
            url: `${baseUrl}/students/${id}`,
            type: 'delete',
            success: function(res){
                resolve(res)
            }
        })
    })
}

// 编辑
function updateStudent(id,obj){
    return new Promise((resolve,reject)=>{
        $.ajax({
            url: `${baseUrl}/students/${id}`,
            type: 'put',
            data: obj,
            success: function(res){
                resolve(res)
            }
        })
    })
}


// 新增
function addStudent(obj){
    return new Promise((resolve,reject)=>{
        $.post(`${baseUrl}/students`,obj,res=>{
            resolve(res)
        })          
    })
}

// 根据id查找
function getByid(id){
    return new Promise((resolve,reject)=>{
        $.get(`${baseUrl}/students/${id}`,res=>{
            resolve(res)
        })          
    })
}